@extends('admin.app')

@section('content')
    @if($skinid == 3)
        <link rel="stylesheet" href="/css/admin/attendance-setting.css?v={{time()}}">
    @elseif($skinid == 1)
        <link rel="stylesheet" href="/css/theme-blue/admin/attendance-setting.css?v={{time()}}">
    @elseif($skinid == 2)
        <link rel="stylesheet" href="/css/theme-pink/admin/attendance-setting.css?v={{time()}}">
    @endif
    <link rel="stylesheet" href="/css/icon/iconfont-0130.css">
    <link rel="stylesheet" href="/css/admin/mobileSelect.css">
    <link rel="stylesheet" href="/css/admin/newadd.css">
    <style>
        #trigger-select-year {
            cursor: pointer;
            text-align: right;
            margin-right: 10px;
            color:#535353;
        }
        .weui-cell__bd.select-year:after{
            content: " ";
            display: inline-block;
            height: 6px;
            width: 6px;
            border-width: 2px 2px 0 0;
            border-color: #c8c8cd;
            border-style: solid;
            -webkit-transform: matrix(.71,.71,-.71,.71,0,0);
            transform: matrix(.71,.71,-.71,.71,0,0);
            position: relative;
            top: -2px;
            position: absolute;
            top: 50%;
            margin-top: -4px;
            right: 12px;
        }
    </style>
    <div class="weui-cell" style="height:30px;">
        <div class="weui-cell__hd">
            <p><i class="icon iconfont icon-kaoqin year-param-icon" style="font-size: 24px;"></i><span style="vertical-align: middle; margin-left: 10px; color:#535353;">选择时间</span></p>
        </div>
        <div class="weui-cell__bd select-year">
            <div id="trigger-select-year">{{$year_param}}</div>
        </div>
    </div>
    <div class="mian-container">
        <div class="attendance-setting">
            <div class="float-section absence-section">
                <div class="left-sec">
                    <a class="add-input" href="javascript:void(0);"></a>
                    <a class="offline-input" href="javascript:void(0);"></a>
                </div>
                <div class="middle-section">
                    <p>缺勤</p><p>对应分值</p>
                    <div class="input-div">
                        <input class="weui-input" type="text" value="迟到">
                        <input class="sub-num weui-input"   type="text"  value="{{$set->late}}"  name="late">
                    </div>
                    <div class="input-div">
                        <input class="weui-input" type="text" value="早退">
                        <input class="sub-num weui-input" type="text" value="{{$set->early}}" name="early">
                    </div>
                    <div class="input-div">
                        <input class="weui-input" type="text" value="旷工">
                        <input class="sub-num weui-input" type="text" value="{{$set->absenteeism}}" name="absenteeism">
                    </div>
                    <div class="input-div">
                        <input class="weui-input" type="text" value="事假">
                        <input class="sub-num weui-input" type="text" value="{{$set->business}}" name="business">
                    </div>
                    <div class="input-div">
                        <input class="weui-input" type="text" value="病假">
                        <input class="sub-num weui-input" type="text" value="{{$set->sick}}" name="sick">
                    </div>
                </div>
            </div>
            <input type="hidden" name="year" value="{{$year_param}}">
            <div class="float-section overtime-section">
                <div class="middle-section">
                    <p>加班时间</p><p>对应分值</p>
                    <div class="input-div">
                        <p class=" weui-input" style="width: 2rem; color: #434343;">1小时</p>

                        <input class="sub-num weui-input" type="text" value="{{$set->overtime}}" name="overtime">
                    </div>
                </div>
            </div>
            <a href="javascript:;" class="weui-btn weui-btn_primary weui-btn_color" id="smt" onclick="ajax_set_update()">确定</a>
        </div>

        @include('sysadmin.admin-caidan')
    </div>
    <div class="fix-message">
        @if($skinid == 3)
            <img src="/img-theme-pink/que-3.png">
        @elseif($skinid == 1)
            <img src="/img-theme-pink/que-2.png">
        @elseif($skinid == 2)
            <img src="/img-theme-pink/que-1.png">
        @endif
    </div>
    <script src="/js/mobileSelect.js"></script>
    <script>
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
        $(document).ready(function () {
            $('.fix-message img').click(function () {
                $.alert("考勤统计包含缺勤、公假、加班，其中公假不记入分值统计，如图为缺勤和加班的默认分值，其中事假和病假的默认数值单位为“天”。（默认分值的设定，以每年200个工作日满分100分计算，每个工作日绩效值约0.5分，以此根据设置适合本企业的缺勤项目分值；以每天7小时工作时间为基础，3倍奖励作为系数，则加班1小时的绩效分值约0.2分）", "提示");
            })
            $('.admin-item').click(function(){
                $('.front-show-hidden').toggle();
            });

            $('.absence-section .input-div')


            $('.kaohe-item').click(function(){
                $('.show-hidden').toggle();
            })
            $('.add-input').click(function(){

                $(this).parent().siblings('.middle-section').append('<div class="input-div">'
                        +'<input type="text">'
                        +'<input class="sub-num" type="text">'
                        +'</div>');
            });

            $('body').on('click','.sub-num',function(){
                $(this).picker({
                    title: "选择分值",
                    cols: [
                        {
                            textAlign: 'center',
                            values: ['5.','4.','3.','2.','1.','0.','-0.','-1.','-2.','-3.','-4.','-5.']
                        },
                        {
                            textAlign: 'center',
                            values: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
                        },
                        {
                            textAlign: 'center',
                            values: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
                        },
                    ],
                    onClose:function(event){
                        event.input.context.value = event.input.context.value.replace(/\s+/g,"");
                    }
                });
            });
        })


        function ajax_set_update() {
            var url='/admin/set/attendance_update';
            var late = $('input[name|="late"]').val();
            var early = $('input[name|="early"]').val();
            var absenteeism = $('input[name|="absenteeism"]').val();
            var business = $('input[name|="business"]').val();
            var sick = $('input[name|="sick"]').val();
            var overtime = $('input[name|="overtime"]').val();
            var year = $('input[name|="year"]').val();
            $.ajax({
                type: 'put',
                cache: 'false',
                url: url,
                data: 'late=' + late + '&early=' + early+ '&absenteeism=' + absenteeism+ '&business=' + business+ '&sick=' + sick+ '&overtime=' + overtime + '&year=' + year,
                dataType: 'json',
                success: function (data) {
                    if (data.status == 'success') {
                        $.toptip(data.msg,'success');
                        window.location.href= data.redirectUrl;
                    } else {
                        $.toptip(data.msg,'error');
                        window.location.href= data.redirectUrl;
                    }
                },
                error: function () {
                    $.toptip('网络异常请重试','warning');
                }
            });
        }
    </script>
    <script>
        $(document).ready(function(){
            var UplinkData = {!! $yearlist !!};
            var mobileSelect3 = new MobileSelect({
                trigger: '#trigger-select-year',
                title: '选择时间',
                wheels: [
                    {data: UplinkData}
                ],
                //     keyMap: {
                //        id:'id',
                //        value: 'name',
                //        childs :'son'
                //      },
                position: [0, 1],
                callback: function (indexArr, data) {
                    //
                    var year = data[0].id;

                    window.location.href = '/admin/set/attendance_edit?year=' + year ;
                    console.log(data[0].id); //返回选中的json数据
                }
            });
        });
    </script>
@endsection


















